﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SsrsRenderStudio.Shared;

namespace SsrsRenderStudio.Configuration
{
    public class LoggingConfig
    {
        public string SourceName = string.Empty;
        public int LoggingVerbosity = 0;
        public TimeSpan LogProcessingInterval = new TimeSpan(0, 0, 30);
        public bool IsImmediate = true;

        public LoggingConfig(string sourceName, int loggingVerbosity, bool isImmediate, TimeSpan logProcessingInterval)
        {
            SourceName = sourceName;
            LoggingVerbosity = loggingVerbosity;
            LogProcessingInterval = logProcessingInterval;
            IsImmediate = isImmediate;
        }
    }

    public class LoggingAction
    {
        public EnumLoggingSeverity Severity = EnumLoggingSeverity.EMERGENCY;
        public EnumLoggingAction Action = EnumLoggingAction.NONE;
        public ParameterHash Parameters = new ParameterHash(null);

        public LoggingAction(EnumLoggingSeverity severity, EnumLoggingAction action, ParameterHash parameters)
        {
            Severity = severity;
            Action = action;
            Parameters = parameters;
        }
    }

    /*
    //DEPRECATED: Replaced by ApplicationConfig
    public class ServerConfig
    {
        public string ServerName = string.Empty;
        public string RemoteConfiguration = string.Empty;

        public ServerConfig(string serverName, string remoteConfiguration)
        {
            ServerName = serverName;
            RemoteConfiguration = remoteConfiguration;
        }
    }
    */

    /// <summary>
    /// Representation of the local application.config file and the type of application this is.
    /// </summary>
    public class ApplicationConfig
    {
        public EnumApplicationType ApplicationType = EnumApplicationType.NONE;
        public string ApplicationName = string.Empty;
        public string RemoteMasterConfiguration = string.Empty;

        public bool IsServer
        {
            get
            {
                return EnumApplicationType.SERVER == ApplicationType;
            }
        }

        public bool IsClient
        {
            get
            {
                return EnumApplicationType.CLIENT == ApplicationType;
            }
        }

        public ApplicationConfig(string applicationType, string applicationName, string remoteMasterConfiguration)
        {
            ApplicationName = applicationName;
            RemoteMasterConfiguration = remoteMasterConfiguration;
            ApplicationType = (EnumApplicationType)Enum.Parse(typeof(EnumApplicationType), applicationType);
        }
    }

    public class EndpointConfig
    {
        public string FriendlyName = string.Empty;
        public string URL = string.Empty;

        public EndpointConfig(string friendlyName, string url)
        {
            FriendlyName = friendlyName;
            URL = url;
        }
    }

    public class AppInfo
    {
        public string FriendlyName = string.Empty;
        public string LoggingSource = string.Empty;
        public string EndpointPointer = string.Empty;

        public AppInfo(string friendlyName, string logging, string endpoint)
        {
            FriendlyName = friendlyName;
            LoggingSource = logging;
            EndpointPointer  = endpoint;
        }
    }

    public class ClientInfo : AppInfo
    {
        public ClientInfo(string friendlyName, string logging, string endpoint)
            : base(friendlyName, logging, endpoint)
        { }
    }

    public class SmtpInfo
    {
        public string SmtpHost = string.Empty;
        public string FromAddress = string.Empty;
        public string FromDisplayName = string.Empty;
        public string AdminEmail = string.Empty;

        public SmtpInfo(string host, string fromAdd, string fromName, string adminEmail)
        {
            SmtpHost = host;
            FromAddress = fromAdd;
            FromDisplayName = fromName;
            AdminEmail = adminEmail;
        }
    }
}
